package com.yun.zf.common.validate.ValidatorUtil;

import cn.hutool.core.util.IdcardUtil;
import com.yun.zf.common.validate.IsCardNo;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class IsCardNoValidator implements ConstraintValidator<IsCardNo,String> {

    private boolean required = false;

    //初始化方法
    @Override
    public void initialize(IsCardNo constraintAnnotation) {
        required = constraintAnnotation.required();
    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
       return   IdcardUtil.isValidCard(s);
    }
}
